home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Borland / Borland C++ V5.02 / LISTCTRL.PAK / WINMAIN.C < prev   
C/C++ Source or Header  |  1997-05-06  |  4KB  |  116 lines

  1. // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
  2. // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
  3. // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
  4. // PARTICULAR PURPOSE.
  5. //
  6. // Copyright (C) 1993-1995  Microsoft Corporation.  All Rights Reserved.
  7. //
  8. //  MODULE:   winmain.c
  9. //
  10. //  PURPOSE:   Calls initialization functions and processes the message loop
  11. //
  12. //
  13. //  PLATFORMS: Windows 95, Windows NT
  14. //
  15. //  FUNCTIONS:
  16. //    WinMain() - calls initialization functions, processes message loop
  17. //
  18. //  COMMENTS:
  19. //
  20. //
  21.  
  22. #include <windows.h>            // required for all Windows applications
  23. #include "globals.h"            // prototypes specific to this application
  24.  
  25. //
  26. //  FUNCTION: WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
  27. //
  28. //  PURPOSE: calls initialization function, processes message loop
  29. //
  30. //  PARAMETERS:
  31. //
  32. //    hInstance - The handle to the instance of this application that
  33. //          is currently being executed.
  34. //
  35. //    hPrevInstance - The handle to the instance of this application
  36. //          that was last executed.  If this is the only instance
  37. //          of this application executing, hPrevInstance is NULL.
  38. //          In Win32 applications, this parameter is always NULL.
  39. //
  40. //    lpCmdLine - A pointer to a null terminated string specifying the
  41. //          command line of the application.
  42. //
  43. //    nCmdShow - Specifies how the main window is to be diplayed.
  44. //
  45. //  RETURN VALUE:
  46. //    If the function terminates before entering the message loop,
  47. //      return FALSE.
  48. //    Otherwise, return the WPARAM value sent by the WM_QUIT message.
  49. //
  50. //
  51. //  COMMENTS:
  52. //
  53. //    Windows recognizes this function by name as the initial entry point
  54. //    for the program.  This function calls the application initialization
  55. //    routine, if no other instance of the program is running, and always
  56. //    calls the instance initialization routine.  It then executes a
  57. //    message retrieval and dispatch loop that is the top-level control
  58. //    structure for the remainder of execution.  The loop is terminated
  59. //    when a WM_QUIT  message is received, at which time this function
  60. //    exits the application instance by returning the value passed by
  61. //    PostQuitMessage().
  62. //
  63. //    If this function must abort before entering the message loop, it
  64. //    returns the conventional value NULL.
  65. //
  66.  
  67. #pragma argsused
  68. int APIENTRY WinMain(HINSTANCE hInstance,
  69.                      HINSTANCE hPrevInstance, 
  70.                      LPSTR     lpCmdLine, 
  71.                      int       nCmdShow)
  72. {
  73.     MSG msg;
  74.     HANDLE hAccelTable;
  75.     
  76.     // Other instances of app running?
  77.     if (!hPrevInstance)
  78.     {
  79.         // Initialize shared things
  80.         if (!InitApplication(hInstance))
  81.         {
  82.             return FALSE;               // Exits if unable to initialize
  83.         }
  84.     }
  85.  
  86.     // Perform initializations that apply to a specific instance
  87.     if (!InitInstance(hInstance, nCmdShow))
  88.     {
  89.         return FALSE;
  90.     }
  91.  
  92.     hAccelTable = LoadAccelerators(hInstance, szAppName);
  93.  
  94.     // Acquire and dispatch messages until a WM_QUIT message is received.
  95.     while (GetMessage(&msg, NULL, 0, 0))
  96.     {
  97.         //
  98.         // **TODO** Add other Translation functions (for modeless dialogs
  99.         //  and/or MDI windows) here.
  100.         //
  101.  
  102.         if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
  103.         {
  104.             TranslateMessage(&msg);
  105.             DispatchMessage(&msg); 
  106.         }
  107.     }
  108.  
  109.     //
  110.     // **TODO** Call module specific instance free/delete functions here.
  111.     //
  112.  
  113.     // Returns the value from PostQuitMessage
  114.     return msg.wParam;
  115. }
  116.